export function searchColumns() {
  return [
    {
      prop: 'name',
      placeholder: '请输入计划名称',
    },

    {
      prop: 'app_page',
      placeholder: '请输入跳转页面',
    },
    {
      type: 'select',
      prop: 'status',
      dicData: [
        { value: 1, label: '开启' },
        { value: 2, label: '禁用' },
        { value: 3, label: '已推送' },
      ],
      placeholder: '请选择计划状态',
    },
  ]
}

export function tableColumns() {
  const statusArr = {
    1: '开启',
    2: '禁用',
    3: '已推送',
  }

  const getCrowdRuleName = row => {
    const a = row?.map(it => {
      return {
        name: this.userGroupList.filter(chil => chil.value === it),
      }
    })

    return a?.map(item => item.name.map(chil => chil?.label)).join('，')
  }
  return [
    {
      width: 80,
      label: '序号',
      prop: 'id',
    },
    {
      align: 'left',
      label: '计划名称',
      prop: 'name',
    },
    {
      align: 'left',
      overHidden: true,
      label: '参与人群',
      prop: 'crowd_rule_ids',
      formatter: row => getCrowdRuleName(row?.crowd_rule_ids),
    },
    {
      label: '预计覆盖人数',
      prop: 'crowd_user_count',
    },
    {
      overHidden: true,
      align: 'left',
      label: '推送标题',
      prop: 'title',
    },
    {
      align: 'left',
      label: '推送内容',
      prop: 'content',
      overHidden: true,
    },
    {
      type: 'img',
      label: '推送封面图',
      prop: 'img_url',
      formatter: row => `${process.env.VUE_APP_CND + row?.img_url}`,
    },
    {
      label: '跳转页面',
      prop: 'page',
      formatter: row => this.pages?.find(item => item?.value === Number(row?.page))?.label,
    },
    {
      width: 140,
      label: '推送时间',
      prop: 'push_time',
      formatter: row => row?.push_time?.map(item => this.$formatTime(item))?.join(','),
    },
    {
      label: '计划状态',
      prop: 'status',
      html: true,
      formatter: row =>
        `<span class="${
          row?.status === 1 ? 'text-success' : row?.status === 2 ? 'text-warning' : 'text-info'
        }">${statusArr[row?.status]}</span>`,
    },
    {
      overHidden: true,
      label: '测试粉丝ID',
      prop: 'user_ids',
      formatter: row => row?.user_ids?.join(','),
    },
  ]
}
